{extend name="base"}
{block name="title"}每日签到奖励{/block}
{block name="head"}{/block}
{block name="body"}
<body class="mainbody">
<form>
<!--导航栏-->
<div class="location">
  <a href="javascript:history.back(-1);" class="back"><i class="iconfont icon-up"></i><span>返回上一页</span></a>
  <a href="{:url('index/home')}" class="home"><i class="iconfont icon-home"></i><span>首页</span></a>
  <i class="arrow iconfont icon-arrow-right"></i>
  <span>每日签到奖励</span>
</div>
<!--/导航栏-->

<div id="floatHead" class="toolbar-wrap">
  <div class="toolbar">
    <div class="box-wrap">
      <a class="menu-btn"><i class="iconfont icon-more"></i></a>
      <div class="l-list">
        <div class="menu-list">
          <div class="rule-single-select">
            <select name="channel" style="display:none">
              <option value="-1">===所有渠道===</option>
              {volist name="CHANNELS" id='val'}
              <option value="{$key}"{eq name="channel" value="$key"} selected{/eq}>[{$key}]{$val.Name}</option>
              {/volist}
            </select>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

<div class="table-container">
  <table class="ltable border-table">
    <thead>
      <tr>
        <th>#</th>
        <th>渠道</th>
        <th>连续第几天</th>
        <th>奖励金币数</th>
        <th>创建时间</th>
        <th>修改时间</th>
        <th>操作</th>
      </tr>
    </thead>
    <tbody>
{empty name="list"}
      <tr><td colspan="7">Oh~暂无数据!</td></tr>
{else/}
    {volist name="list" id="v"}
      <tr data-id="{$v.ID}" data-gold="{$v.RewardGold}">
        <td>{$v.ID}</td>
        <td title="{$v.Channel}">{$CHANNELS[$v.Channel]['Name'] ?? '--'}</td>
        <td>{$v.DayID}</td>
        <td>{$v.RewardGold}</td>
        <td>{$v.CreateTime}</td>
        <td>{$v.UpdateTime}</td>
        <td><input type="button" value="修改" /></td>
      </tr>
    {/volist}
{/empty}
    </tbody>
  </table>
</div>

<div class="page-footer"><div class="btn-wrap">{$list->render()}</div></div>

</form>
<script>
$(function () {
  // 修改奖励金币
  $('input[type=button]').click(function () {
    var tr = $(this).parents('tr');
    var id = tr.data('id');
    var gold = tr.data('gold');

    dialog({
      title: '修改奖励金币[' + id + ']',
      content: '<input type="text" class="input" placeholder="请输入要修改的金币数" value="' + gold + '" />',
      okValue: '确定',
      cancelValue: '取消',
      cancel: function () {},
      ok: function () {
        var a = $(this.node);
        var p = $('.input', a);
        var v = p.val();
        $.post("{:url('UpdateCoin')}", {
          id: id,
          gold: v
        }, function (resp, text, xhr) {
          console.log(resp);
          alert(resp.error);
          if (resp.errno == 0 || resp.errno == 110) {
            location.reload();
          }
        });
        return false;
      }
    }).showModal();
  });

});
</script>
</body>
{/block}